#include "../fem/Matrix.h"


#include "gtest/gtest.h"

TEST(Matrix3, construction)
{
	Matrix3 m1 = Matrix3();
	m1.Fill(0.0);
	for(int i=0; i<DIM; i++)
		for(int j=0; j<DIM; j++)
			EXPECT_EQ(0.0, m1(i, j));
	
	Matrix3 m2 = Matrix3();
	Vector3 a = Vector3(1.0, 2.0, 3.0);
	Vector3 b = Vector3(-1.0, -2.0, -3.0);
	Vector3 c = Vector3(0.0, 1.0, 0.0);
	m2.SetVectors(a, b, c);
	EXPECT_EQ(1.0, m2(0, 0));
	EXPECT_EQ(2.0, m2(1, 0));
	EXPECT_EQ(3.0, m2(2, 0));
	EXPECT_EQ(-1.0, m2(0, 1));
	EXPECT_EQ(-2.0, m2(1, 1));
	EXPECT_EQ(-3.0, m2(2, 1));
	EXPECT_EQ(0.0, m2(0, 2));
	EXPECT_EQ(1.0, m2(1, 2));
	EXPECT_EQ(0.0, m2(2, 2));

}

TEST(Matrix3, Trace)
{
	Matrix3 m = Matrix3();
	m.SetVectors(Vector3(1.0, 0.0, 0.0), Vector3(0.0, -2.0, 0.0), Vector3(0.0, 1.0, 0.0));
	EXPECT_EQ(-1.0, m.Trace());
}

TEST(Matrix3, Determinant)
{
	Matrix3 m = Matrix3();
	m.SetVectors(Vector3(1.0, 0.0, 0.0), Vector3(0.0, -2.0, 0.0), Vector3(0.0, 1.0, 0.0));
	EXPECT_EQ(0.0, m.Determinant());
	m.SetVectors(Vector3(1.0, 0.0, 0.0), Vector3(0.0, -2.0, 0.0), Vector3(0.0, 1.0, 1.0));
	EXPECT_EQ(-2.0, m.Determinant());
	m.SetVectors(Vector3(1.0, 1.0, 1.0), Vector3(1.0, -2.0, 1.0), Vector3(1.0, 1.0, 1.0));
	EXPECT_EQ(0.0, m.Determinant());
	m.SetVectors(Vector3(1.0, 1.0, 1.0), Vector3(1.0, -2.0, 1.0), Vector3(1.0, 1.0, 2.0));
	EXPECT_EQ(-3.0, m.Determinant());
}